package com.appbee.media.server;

import java.util.ArrayList;
import java.util.List;

import javax.inject.Inject;

import com.appbee.core.server.requestfactory.BaseService;
import com.google.appengine.api.blobstore.BlobstoreService;

public class MediaService extends BaseService<Media,MediaDAO>
{
	private BlobstoreService blobstoreService;
	
	@Inject
	public MediaService(BlobstoreService blobstoreService)
	{
		this.blobstoreService = blobstoreService;
	}
	
	public Media findById(long id)
	{
		return daoProvider.get().findById(id);
	}

	public List<Media> findByRange(int start,int size)
	{
		return daoProvider.get().findByRange(start, size);
	}
	
	public Media save(Media bean)
	{
		daoProvider.get().saveAllTransaction(bean);
		return bean;
	}

	public void delete(Media photo)
	{
		daoProvider.get().delete(photo);
	}
	
	public List<String> createUploadUrl(int size)
	{
		List<String> list = new ArrayList<String>();
		for(int i=0;i<size;i++)
		{
			list.add(blobstoreService.createUploadUrl("/upload"));
		}
		return list;
	}
	
	
}
